package com.example.protocol.mqtt;

import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.springframework.stereotype.Service;

/**
 * 目前设想是每来一次消息就new这个类，这个类实现了Runnable接口，会是一个新线程
 * 设想是在新线程里面进行callBackHandler类的handle操作，不影响mqtt客户端的消息接收
 */
public class HandlerThread implements Runnable {
    CallBackHandler callBackHandler;
    MqttMessage msg;

    HandlerThread(MqttMessage msg, CallBackHandler callBackHandler) {
        this.msg = msg;
        this.callBackHandler = callBackHandler;
    }

    @Override
    public void run() {
        callBackHandler.handleTopic(msg);
    }
}
